/**
 * 
 */
package cx3k.GUI;

import java.util.ArrayList;

import cx3k.scheduler.objects.Course;
import cx3k.scheduler.objects.util.CompareUtil;

/**
 * @author Chris
 *
 */
public class ScheduledCourseGroup {
	ArrayList<Course> courses;
	
	public ScheduledCourseGroup() {
		this.courses = new ArrayList<Course>();
	}
	
	public ScheduledCourseGroup(Course course){
		courses = new ArrayList<Course>();
		courses.add(course);
	}
	
	public ScheduledCourseGroup(ArrayList<Course> courses){
		this.courses = courses;
	}
	
	public ScheduledCourseGroup(ScheduledCourseGroup newSchedCrsGrp) {
		this(newSchedCrsGrp.getCourses()[0]);
		Course [] tempCourses = newSchedCrsGrp.getCourses();
		for(int i = 1; i < tempCourses.length; i++ ){
			this.addCourse(tempCourses[i]);
		}
		
	}

	public void addCourse(Course c) {
		this.courses.add(c);
	}
	
	public Course[] getCourses(){
		Course[] c = new Course[courses.size()];
		
		int i = 0;
		for (Course course: courses) {
			c[i++] = course; 
		}
		
		return c;
	}
	
	public ArrayList<Course> getCoursesList() {
		return this.courses;
	}

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub

	}
	
	@Override
	public boolean equals(Object myObject)
	{

	ScheduledCourseGroup myGroup = (ScheduledCourseGroup) myObject;

	ArrayList<Course> myCourses1 = courses;
	ArrayList<Course> myCourses2 = myGroup.courses;

	Course myCourse;

	for(int x = 0; x < myCourses1.size(); x++){ 
	myCourse = myCourses1.get(x); 
	for(int y = 0; y < myCourses2.size(); y++) 
	if(CompareUtil.Equals(myCourse, myCourses2.get(y))) return true; 
	}

	return false;

	}

}